package com.gitee.melin.bee.core.jdbc.parser;

import com.gitee.melin.bee.core.jdbc.enums.DataSourceType;
import java.util.regex.Pattern;

public class SnowflakeURLParser extends AbstractMatcherURLParser {
    private static final Pattern URL_PATTERN =
            Pattern.compile("jdbc:snowflake:\\/\\/(?<host>[^:\\/]+)(:(?<port>\\d+))?\\/(\\?)?(?<options>.*)?");

    public SnowflakeURLParser() {
        super(URL_PATTERN, DataSourceType.SNOWFLAKE);
    }

    @Override
    protected String parseDbName(String dbOptions) {
        return parserOptions(dbOptions).getOrDefault("db", null);
    }
}
